﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System.Linq
{
    public static class DateTimeHelper
    {
        public static DateTime? ToServerTime(this DateTime? source)
        {
            return source != null ? new DateTime?(source.Value.ToServerTime()) : null;
        }

        public static DateTime? ToDBTime(this DateTime? source)
        {
            return source != null ? new DateTime?(source.Value.ToDBTime()) : null;
        }

        public static DateTime ToServerTime(this DateTime source)
        {
            return DateTime.SpecifyKind(source, DateTimeKind.Utc).ToLocalTime();
        }

        public static DateTime ToDBTime(this DateTime source)
        {
            return DateTime.SpecifyKind(source, DateTimeKind.Local).ToUniversalTime();
        }
    }
}
